package com.px.task.controller;

import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.core.page.TableDataInfo;
import com.px.common.enums.BusinessType;
import com.px.common.utils.poi.ExcelUtil;
import com.px.framework.aes.AesSecurityParameter;
import com.px.task.domain.TaskRecordOsd;
import com.px.task.service.ITaskRecordOsdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 任务记录OSD信息Controller
 *
 * @author WRJ
 * @date 2024-08
 */
@Api("任务记录OSD信息")
@RestController
@RequestMapping("/task/record/osd")
public class TaskRecordOsdController extends BaseController
{
    @Autowired
    private ITaskRecordOsdService taskRecordOsdService;

    /**
     * 查询任务记录OSD信息列表
     */
    @ApiOperation("查询任务记录OSD信息列表")
    @PreAuthorize("@ss.hasPermi('task:record:query')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(TaskRecordOsd taskRecordOsd)
    {
        startPage();
        List<TaskRecordOsd> list = taskRecordOsdService.selectTaskRecordOsdList(taskRecordOsd);
        return getDataTable(list);
    }

    /**
     * 导出任务记录OSD信息列表
     */
    @ApiOperation("导出任务记录OSD信息列表")
    @PreAuthorize("@ss.hasPermi('task:record:query')")
    @Log(title = "任务记录OSD信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter(outEncode = false)
    public void export(HttpServletResponse response, TaskRecordOsd taskRecordOsd)
    {
        List<TaskRecordOsd> list = taskRecordOsdService.selectTaskRecordOsdList(taskRecordOsd);
        ExcelUtil<TaskRecordOsd> util = new ExcelUtil<TaskRecordOsd>(TaskRecordOsd.class);
        util.exportExcel(response, list, "任务记录OSD信息数据");
    }

    /**
     * 获取任务记录OSD信息详细信息
     */
    @ApiOperation("获取任务记录OSD信息详细信息")
    @PreAuthorize("@ss.hasPermi('task:record:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskRecordOsdService.selectTaskRecordOsdById(id));
    }

    /**
     * 新增任务记录OSD信息
     */
    @ApiOperation("新增任务记录OSD信息")
    @PreAuthorize("@ss.hasPermi('task:record:edit')")
    @Log(title = "任务记录OSD信息", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody TaskRecordOsd taskRecordOsd)
    {
        return toAjax(taskRecordOsdService.insertTaskRecordOsd(taskRecordOsd));
    }

    /**
     * 修改任务记录OSD信息
     */
    @ApiOperation("修改任务记录OSD信息")
    @PreAuthorize("@ss.hasPermi('task:record:edit')")
    @Log(title = "任务记录OSD信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody TaskRecordOsd taskRecordOsd)
    {
        return toAjax(taskRecordOsdService.updateTaskRecordOsd(taskRecordOsd));
    }

    /**
     * 删除任务记录OSD信息
     */
    @ApiOperation("删除任务记录OSD信息")
    @PreAuthorize("@ss.hasPermi('task:record:remove')")
    @Log(title = "任务记录OSD信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskRecordOsdService.deleteTaskRecordOsdByIds(ids));
    }
}
